package com.beidasoft.web.util;

/**
 * Created by hoax on 2019-09-18 19:00.
 */
public class FileSelfProcUtils {
    static String[] fileTypeBuff = {
            //文档类
            "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "pdf", "wps",
            //图片类
            "jpg", "jpeg", "png", "gif",
            //影音类
            "avi", "mp4", "mp3", "wav",
            //其他
            "zip", "rar"};


    public static boolean checkFileTypeByName(String fileName) {
        boolean isPass = false;
        if (fileName != null && !"".equals(fileName)) {
            Integer chIndex = fileName.lastIndexOf(".");
            if (chIndex != -1 && chIndex != fileName.length()) {
                String fileType = fileName.substring(chIndex + 1);
                fileType = fileType.toLowerCase();
                for (String type : fileTypeBuff) {
                    if (type.equals(fileType)) {
                        return true;
                    }
                }
            }
        }
        return isPass;
    }
}
